package com.example.binpacking.model;

//import com.example.binpacking.config.QuoteStringSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.*;

import java.util.Collections;
import java.util.List;

@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString

public class ResultMessage {
    private int code;
    private String msg;

//    @JsonSerialize(using = QuoteStringSerializer.class)
    private List<Object> data;

    // Constructors, getters, setters...

    public static ResultMessage success(int code, String msg, List<Object> data) {
        ResultMessage ResultMessage = new ResultMessage();
        ResultMessage.setCode(code);
        ResultMessage.setMsg(msg);
        ResultMessage.setData(data);
        return ResultMessage;
    }

    public static ResultMessage fail(String msg) {
        ResultMessage ResultMessage = new ResultMessage();
        ResultMessage.setCode(200);
        ResultMessage.setMsg(msg);
        ResultMessage.setData(Collections.emptyList());
        return ResultMessage;
    }

    public static ResultMessage fail(int code, String msg, List<Object> data) {
        ResultMessage ResultMessage = new ResultMessage();
        ResultMessage.setCode(code);
        ResultMessage.setMsg(msg);
        ResultMessage.setData(data);
        return ResultMessage;
    }
}
